/**
 * 
 */
package soa.security.mgr.service;

import java.util.List;
import java.util.Map;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;

import soa.security.domain.Department;
import soa.security.domain.Group;
import soa.security.domain.Organization;
import soa.security.domain.Person;
import soa.security.domain.Position;
import soa.security.domain.Role;
import soa.security.exception.OrganizationException;
import soa.security.mgr.service.base.BaseMgrService;
import soa.security.ws.base.ModelAdapter;

/**
 * @author CreGu
 *
 */
public interface DepartmentMgrService extends BaseMgrService,
		ModelAdapter<Department> {

	void addDepartment(String organizationId, Department department)
			throws OrganizationException;

	void updateDepartment(String organizationId, Department a)
			throws OrganizationException;

	public boolean addPersons(String organizationId, String departmentId,
			String personIds) throws OrganizationException;

	boolean removePersons(String organizationId, String departmentId,
			String personIds) throws OrganizationException;

	boolean addPositions(String organizationId, String departmentId,
			String positionIds) throws OrganizationException;

	boolean removePositions(String organizationId, String departmentId,
			String positionIds) throws OrganizationException;

	boolean addGroups(String organizationId, String departmentId,
			String groupIds) throws OrganizationException;

	boolean removeGroups(String organizationId, String departmentId,
			String groupIds) throws OrganizationException;

	boolean addRoles(String organizationId, String departmentId, String roleIds)
			throws OrganizationException;

	boolean removeRoles(String organizationId, String departmentId,
			String roleIds) throws OrganizationException;

	List<Department> allDepartments(String organizationId)
			throws OrganizationException;

	List<Department> allDepartments(String organizationId,
			Map<String, Object> parameters, boolean subTree) throws OrganizationException;

	List<Department> allSubDepartments(String organizationId, String parentBid)
			throws OrganizationException;

	List<Department> allSubDepartments(String organizationId, String parentBid,
			Map<String, Object> parameters) throws OrganizationException;

	List<Department> getDepartment(String organizationId, String departmentId)
			throws OrganizationException;

	List<Person> allPersons(String organizationId, String departmentId)
			throws OrganizationException;
	
	Page<Person> allPersons(String organizationId, String departmentId, PageRequest request)
			throws OrganizationException;

	List<Position> allPositions(String organizationId, String departmentId)
			throws OrganizationException;

	List<Group> allGroups(String organizationId, String departmentId)
			throws OrganizationException;

	List<Role> allRoles(String organizationId, String departmentId)
			throws OrganizationException;

	Department findByDn(String dn) throws OrganizationException;

	boolean deleteByDn(String dn) throws OrganizationException;

	Department findByBid(String baseDn, String bid);

	void removePersonsOther(String organizationId, String dids, String pids);
	
	public Department existByName(String name);
	
	public Department existByGradeCode(String gradeCode);
	
	/**
	 * 查找某机构人员所属部门
	 * @param organizationId
	 * @param person
	 * @return List<Department>
	 * @author CY
	 */
	public List<Department> findDepartmentByPerson(String organizationId, Person person);
}
